package com.hsp.demo_10.singletonpattern;

import org.omg.SendingContext.RunTime;

public class Demo_02 {
    public static void main(String[] args) {
        /*
        单例模式值懒汉式
         */
//        BB instance = BB.getInstance();


    }
}

class BB{

    public static int count =1 ;

    //2、在类的内部创建对象
    private static  BB bb;

    //1、构造器私有化
    private BB(){
        System.out.println("BB对象的创建");
    }

    //3、对外暴露公共方法，返回类的对象
    public static BB getInstance(){
        if(bb == null){
            bb = new BB();
        }
        return bb;
    }
}